package com.yaorange.web.controller.nongit;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yaorange.common.annotation.Log;
import com.yaorange.common.core.controller.BaseController;
import com.yaorange.common.core.domain.AjaxResult;
import com.yaorange.common.enums.BusinessType;
import com.yaorange.nongit.domain.NjtAdminPrinterCert;
import com.yaorange.nongit.service.INjtAdminPrinterCertService;
import com.yaorange.common.utils.poi.ExcelUtil;
import com.yaorange.common.core.page.TableDataInfo;

/**
 * 打印机认证情况Controller
 * 
 * @author lzh
 * @date 2025-02-28
 */
@RestController
@RequestMapping("/nongit/printercert")
public class NjtAdminPrinterCertController extends BaseController
{
    @Autowired
    private INjtAdminPrinterCertService njtAdminPrinterCertService;

    /**
     * 查询打印机认证情况列表
     */
    @PreAuthorize("@ss.hasPermi('nongit:printercert:list')")
    @GetMapping("/list")
    public TableDataInfo list(NjtAdminPrinterCert njtAdminPrinterCert)
    {
        startPage();
        List<NjtAdminPrinterCert> list = njtAdminPrinterCertService.selectNjtAdminPrinterCertList(njtAdminPrinterCert);
        return getDataTable(list);
    }

    /**
     * 导出打印机认证情况列表
     */
    @PreAuthorize("@ss.hasPermi('nongit:printercert:export')")
    @Log(title = "打印机认证情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NjtAdminPrinterCert njtAdminPrinterCert)
    {
        List<NjtAdminPrinterCert> list = njtAdminPrinterCertService.selectNjtAdminPrinterCertList(njtAdminPrinterCert);
        ExcelUtil<NjtAdminPrinterCert> util = new ExcelUtil<NjtAdminPrinterCert>(NjtAdminPrinterCert.class);
        util.exportExcel(response, list, "打印机认证情况数据");
    }

    /**
     * 获取打印机认证情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('nongit:printercert:query')")
    @GetMapping(value = "/{printerId}")
    public AjaxResult getInfo(@PathVariable("printerId") Long printerId)
    {
        return success(njtAdminPrinterCertService.selectNjtAdminPrinterCertByPrinterId(printerId));
    }

    /**
     * 新增打印机认证情况
     */
    @PreAuthorize("@ss.hasPermi('nongit:printercert:add')")
    @Log(title = "打印机认证情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NjtAdminPrinterCert njtAdminPrinterCert)
    {
        return toAjax(njtAdminPrinterCertService.insertNjtAdminPrinterCert(njtAdminPrinterCert));
    }

    /**
     * 修改打印机认证情况
     */
    @PreAuthorize("@ss.hasPermi('nongit:printercert:edit')")
    @Log(title = "打印机认证情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NjtAdminPrinterCert njtAdminPrinterCert)
    {
        return toAjax(njtAdminPrinterCertService.updateNjtAdminPrinterCert(njtAdminPrinterCert));
    }

    /**
     * 删除打印机认证情况
     */
    @PreAuthorize("@ss.hasPermi('nongit:printercert:remove')")
    @Log(title = "打印机认证情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{printerIds}")
    public AjaxResult remove(@PathVariable Long[] printerIds)
    {
        return toAjax(njtAdminPrinterCertService.deleteNjtAdminPrinterCertByPrinterIds(printerIds));
    }
}
